/*
 * OpenMusicPlayerApp.java
 */

package openmusicplayer;

import java.util.regex.*;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class OpenMusicPlayerApp extends SingleFrameApplication
{
    //generating a new list of current songs
    public static songListDataStructure currentSongs = new songListDataStructure();

    /**
     * At startup create and show the main frame of the application.
     */
    @Override protected void startup() {
        show(new OpenMusicPlayerView(this));
    }

    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window root) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of OpenMusicPlayerApp
     */
    public static OpenMusicPlayerApp getApplication() {
        return Application.getInstance(OpenMusicPlayerApp.class);
    }

    /**
     * This method takes the file path of a (current) song.
     * @return Only the name of the chosen song, not the whole path of it.
     */
    public static String splitPathToTitle(String filePath)
    {
        String[] result;
        //Pattern pattern = Pattern.compile("(.)*/[A-Za-z0-9].wav");
        //Matcher m = pattern.matcher(filePath);
        result = filePath.split("/");
        return result[result.length-1];
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(OpenMusicPlayerApp.class, args);
    }
}
